home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / src / java / awt / toolki~1.jav < prev    next >
Encoding:
Text File  |  1996-01-12  |  7.3 KB  |  235 lines

  1. /*
  2.  * @(#)Toolkit.java    1.46 95/12/14 Sami Shaio
  3.  *
  4.  * Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. package java.awt;
  21.  
  22. import java.awt.peer.*;
  23. import java.awt.image.ImageObserver;
  24. import java.awt.image.ImageProducer;
  25. import java.awt.image.ColorModel;
  26. import java.net.URL;
  27.  
  28. /**
  29.  * An AWT toolkit. It is used to bind the abstract AWT classes
  30.  * to a particular native toolkit implementation.
  31.  *
  32.  * @version     1.46, 12/14/95
  33.  * @author    Sami Shaio
  34.  * @author    Arthur van Hoff
  35.  */
  36. public abstract class  Toolkit {
  37.  
  38.     /**
  39.      * Uses the specified Peer interface to create a new Button.
  40.      * @param target the Button to be created
  41.      */
  42.     protected abstract ButtonPeer     createButton(Button target);
  43.  
  44.     /**
  45.      * Uses the specified Peer interface to create a new TextField.      
  46.      * @param target the TextField to be created
  47.      */
  48.     protected abstract TextFieldPeer     createTextField(TextField target);
  49.  
  50.     /**
  51.      * Uses the specified Peer interface to create a new Label.      
  52.      * @param target the Label to be created
  53.      */
  54.     protected abstract LabelPeer     createLabel(Label target);
  55.  
  56.     /**
  57.      * Uses the specified Peer interface to create a new List.      
  58.      * @param target the List to be created
  59.      */
  60.     protected abstract ListPeer     createList(List target);
  61.  
  62.     /**
  63.      * Uses the specified Peer interface to create a new Checkbox.      
  64.      * @param target the Checkbox to be created
  65.      */
  66.     protected abstract CheckboxPeer     createCheckbox(Checkbox target);
  67.  
  68.     /**
  69.      * Uses the specified Peer interface to create a new Scrollbar.      
  70.      * @param target the Scrollbar to be created
  71.      */
  72.     protected abstract ScrollbarPeer     createScrollbar(Scrollbar target);
  73.  
  74.     /**
  75.      * Uses the specified Peer interface to create a new TextArea.      
  76.      * @param target the TextArea to be created
  77.      */
  78.     protected abstract TextAreaPeer      createTextArea(TextArea target);
  79.  
  80.     /**
  81.      * Uses the specified Peer interface to create a new Choice.      
  82.      * @param target the Choice to be created
  83.      */
  84.     protected abstract ChoicePeer    createChoice(Choice target);
  85.  
  86.     /**
  87.      * Uses the specified Peer interface to create a new Frame.
  88.      * @param target the Frame to be created
  89.      */
  90.     protected abstract FramePeer      createFrame(Frame target);
  91.  
  92.     /**
  93.      * Uses the specified Peer interface to create a new Canvas.
  94.      * @param target the Canvas to be created
  95.      */
  96.     protected abstract CanvasPeer     createCanvas(Canvas target);
  97.  
  98.     /**
  99.      * Uses the specified Peer interface to create a new Panel.
  100.      * @param target the Panel to be created
  101.      */
  102.     protected abstract PanelPeer      createPanel(Panel target);
  103.  
  104.     /**
  105.      * Uses the specified Peer interface to create a new Window.
  106.      * @param target the Window to be created
  107.      */
  108.     protected abstract WindowPeer      createWindow(Window target);
  109.  
  110.     /**
  111.      * Uses the specified Peer interface to create a new Dialog.
  112.      * @param target the Dialog to be created
  113.      */
  114.     protected abstract DialogPeer      createDialog(Dialog target);
  115.  
  116.     /**
  117.      * Uses the specified Peer interface to create a new MenuBar.
  118.      * @param target the MenuBar to be created
  119.      */
  120.     protected abstract MenuBarPeer      createMenuBar(MenuBar target);
  121.  
  122.     /**
  123.      * Uses the specified Peer interface to create a new Menu.
  124.      * @param target the Menu to be created
  125.      */
  126.     protected abstract MenuPeer      createMenu(Menu target);
  127.  
  128.     /**
  129.      * Uses the specified Peer interface to create a new MenuItem.
  130.      * @param target the MenuItem to be created
  131.      */
  132.     protected abstract MenuItemPeer      createMenuItem(MenuItem target);
  133.  
  134.     /**
  135.      * Uses the specified Peer interface to create a new FileDialog.
  136.      * @param target the FileDialog to be created
  137.      */
  138.     protected abstract FileDialogPeer    createFileDialog(FileDialog target);
  139.  
  140.     /**
  141.      * Uses the specified Peer interface to create a new CheckboxMenuItem.
  142.      * @param target the CheckboxMenuItem to be created
  143.      */
  144.     protected abstract CheckboxMenuItemPeer    createCheckboxMenuItem(CheckboxMenuItem target);
  145.  
  146.     /**
  147.      * Gets the size of the screen.
  148.      */
  149.     public abstract Dimension getScreenSize();
  150.  
  151.     /**
  152.      * Returns the screen resolution in dots-per-inch.
  153.      */
  154.     public abstract int getScreenResolution();
  155.  
  156.     /**
  157.      * Returns the ColorModel of the screen.
  158.      */
  159.     public abstract ColorModel getColorModel();
  160.  
  161.     /**
  162.      * Returns the names of the available fonts.
  163.      */
  164.     public abstract String[] getFontList();
  165.  
  166.     /**
  167.      * Returns the screen metrics of the font.
  168.      */
  169.     public abstract FontMetrics getFontMetrics(Font font);
  170.  
  171.     /**
  172.      * Syncs the graphics state; useful when doing animation.
  173.      */
  174.     public abstract void sync();
  175.  
  176.     /**
  177.      * The default toolkit.
  178.      */
  179.     private static Toolkit toolkit;
  180.  
  181.     /**
  182.      * Returns the default toolkit. This is controlled by the
  183.      * "awt.toolkit" property.
  184.      * @exception AWTError Toolkit not found or could not be instantiated.
  185.      */
  186.     public static synchronized Toolkit getDefaultToolkit() {
  187.     if (toolkit == null) {
  188.         String nm = System.getProperty("awt.toolkit", "sun.awt.motif.MToolkit");
  189.         try {
  190.         toolkit = (Toolkit)Class.forName(nm).newInstance();
  191.         } catch (ClassNotFoundException e) {
  192.         throw new AWTError("Toolkit not found: " + nm);
  193.         } catch (InstantiationException e) {
  194.         throw new AWTError("Could not instantiate Toolkit: " + nm);
  195.         } catch (IllegalAccessException e) {
  196.         throw new AWTError("Could not access Toolkit: " + nm);
  197.         }
  198.     }
  199.     return toolkit;
  200.     }
  201.  
  202.     /**
  203.      * Returns an image which gets pixel data from the specified file.
  204.      * @param filename the file containing the pixel data in one of
  205.      * the recognized file formats
  206.      */
  207.     public abstract Image getImage(String filename);
  208.  
  209.     /**
  210.      * Returns an image which gets pixel data from the specified URL.
  211.      * @param url the URL to use in fetching the pixel data
  212.      */
  213.     public abstract Image getImage(URL url);
  214.  
  215.     /**
  216.      * Prepares an image for rendering on the default screen at the
  217.      * specified width and height.
  218.      */
  219.     public abstract boolean prepareImage(Image image, int width, int height,
  220.                      ImageObserver observer);
  221.  
  222.     /**
  223.      * Returns the status of the construction of the indicated method
  224.      * at the indicated width and height for the default screen.
  225.      */
  226.     public abstract int checkImage(Image image, int width, int height,
  227.                    ImageObserver observer);
  228.  
  229.     /**
  230.      * Creates an image with the specified image producer.
  231.      * @param producer the image producer to be used
  232.      */
  233.     public abstract Image createImage(ImageProducer producer);
  234. }
  235.